import {getGoodDetail} from '@/ajax'
const state = {
  detailInfo: {}
}
const actions = {
  //定义得到商品详情函数
  async getGoodDetail({commit},stuId) {
    const {data,code} = await getGoodDetail(stuId)
    if(code === 200)
    //把数据提交到mutations中
    commit('GETGOODDETAIL',data)
  }
}
const mutations = {
  GETGOODDETAIL(state,data) {
    state.detailInfo = data
  }
}
const getters = {
  //导航
  categoryView(state) {
    return state.detailInfo.categoryView || {}
  },
  //商品信息
  skuInfo(state) {
    return state.detailInfo.skuInfo || {}
  },
  //商品属性
  spuSaleAttrList(state) {
    return state.detailInfo.spuSaleAttrList || []
  }
}
export default {
  state,
  actions,
  mutations,
  getters
}